package com.itheima.core.feign;

import com.itheima.common.dto.PageRequestDto;
import com.itheima.common.vo.PageResultVo;
import com.itheima.common.vo.ResultVo;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;

import java.io.Serializable;
import java.util.List;

/**
 * @version 1.0
 * @description 标题
 * @package com.itheima.core.feign
 */
public interface CoreFeign<T> {

    @DeleteMapping("/del/{id}")
    ResultVo deleteById(@PathVariable(name = "id") Serializable id);
    /**
     * 添加记录
     *
     * @param record
     * @return
     */
    @PostMapping("/save")
    ResultVo<T> save(@RequestBody T record);

    //更新数据
    @PutMapping
    ResultVo updateByPrimaryKey(@RequestBody T record);

    @GetMapping("/{id}")
    ResultVo<T> findById(@PathVariable(name = "id") Serializable id) ;

    @GetMapping
    ResultVo<List<T>> findAll() ;

    /**
     * 根据等号条进行查询调用
     * @param record
     * @return
     */
    @PostMapping("/listCondition")
    ResultVo<List<T>> findByRecord(@RequestBody T record);

    /**
     * 通用条件分页查询
     *
     * @param pageRequestDto
     * @return
     */
    @PostMapping(value = "/list")
    PageResultVo<T> findByPage(@RequestBody PageRequestDto pageRequestDto) ;
}
